﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace EliteInfos
{
    class Program
    {
        static void Main(string[] args)
        {
            var infoProg = new InfoProgram();
            var client = new Client();
            client.OnMessageReceived += infoProg.GetMessage;

            infoProg.Main(args);

            var tasks = new Task[] {
            Task.Factory.StartNew(() =>
                {
            Int32 port = 13000;
            IPAddress ipadress = null;

            var adressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            for (int i = 0; i < adressList.Count(); i++)
            {
                if (adressList[i].ToString().Length > 8)
                {
                    ipadress = adressList[i];
                    break;
                }
            }
            client.Connect(ipadress.ToString(), port);
            client.Loop();
            })
            };

            Task.WaitAny(tasks[0]);
        }
    }
}
